Skip to content

fix: add --stdio flag to Cangjie LSPServer spawn#5

Draft
Copilot wants to merge 5 commits into
cangjiefrom
copilot/fix-cangjie-lsp-initialization
Draft

fix: add --stdio flag to Cangjie LSPServer spawn#5
Copilot wants to merge 5 commits into
cangjiefrom
copilot/fix-cangjie-lsp-initialization

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 11, 2026

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Cangjie LSPServer was spawned with no arguments (spawn(bin, [])), so it never entered stdio JSON-RPC mode. The process would start but couldn't communicate with the LSP client, appearing dead in the task manager despite the TUI indicator showing active.

Additionally, LSPServer dynamically links libcangjie-lsp.so from the SDK's tools/lib/ — users must source envsetup.sh to set LD_LIBRARY_PATH before running opencode, otherwise the process exits immediately with code 127.

- const proc = spawn(bin, [], {
+ const proc = spawn(bin, ["--stdio"], {

Log message also updated to guide users toward source envsetup.sh.

How did you verify your code works?

Downloaded the actual Cangjie SDK (cangjie-sdk-linux-x64-1.0.5.tar.gz), configured the environment via source envsetup.sh, and ran LSPServer --stdio with a full LSP initialize handshake. Server responded with 17 capabilities ("Cangjie language server v1.0"). Confirmed without LD_LIBRARY_PATH the process fails with exit code 127 (libcangjie-lsp.so: cannot open shared object file).

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 11, 2026 15:54
…ation

The Cangjie LSPServer requires --stdio to communicate via stdin/stdout
using JSON-RPC. Without this flag, the server either exits immediately
or uses a different communication mode, causing it to not effectively
run despite the TUI indicator showing it as active.

Co-authored-by: SunriseSummer <[email protected]>
Copilot AI changed the title [WIP] Fix initialization of Cangjie LSP in opencode fix: add --stdio flag to Cangjie LSPServer spawn Mar 11, 2026
Copilot AI and others added 2 commits March 11, 2026 16:47
LSPServer requires libcangjie-lsp.so from the SDK's tools/lib directory.
Without LD_LIBRARY_PATH, the process fails immediately with exit code 127.

Changes:
- Auto-download Cangjie SDK tar.gz if LSPServer not found (linux-x64)
- Set CANGJIE_HOME and LD_LIBRARY_PATH when spawning LSPServer
- Derive SDK home from binary path for user-installed SDKs too
- Update cjfmt formatter to also resolve from auto-installed SDK

Co-authored-by: SunriseSummer <[email protected]>
…n PATH

Users are expected to install Cangjie SDK and source envsetup.sh to set
PATH, LD_LIBRARY_PATH, and CANGJIE_HOME before running opencode.

The only code change from original is adding --stdio to LSPServer spawn.

Co-authored-by: SunriseSummer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants